#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QLabel>
#include "ResultManager.h"
#include "HalconCpp.h"
#include "bgaimageprocess.h"
#include "lgaimageprocess.h"
#include "imagesavemanager.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
	void TeachingTest();
	
signals:
	void TeachingFinishedEvent();
private:
	RUN_ENV m_re;
 //   int m_totalTimes;
 //   int m_successTimes;
 //   int m_failTimes;
	//bool m_bSite0;
	double m_lastMeanGray;
	//QString m_lotName;
	/*QString m_productNum;
	QString m_operatorName;*/
	//QString m_testNum;
	QLabel *m_labelBypass;
	QLabel *m_labelState;
    Ui::MainWindow *ui;
    void AddSlots();
    void AddTimeShow();
    void AddCameraShow();
    void UpdateResultList(ResultManager::ERROR_TYPE b, QDateTime time);
    void SaveResultToFile(ResultManager::ERROR_TYPE b, QString path, QDateTime time);
    void UpdateLcdNumbers();
    void closeEvent(QCloseEvent *event);

	void SendResultToHandler(uint8_t b);
	void UpdateUIWithResult(ResultManager::ERROR_TYPE b, QDateTime time, BOOL bLight);
	void StartAction(int index);

	//void StartAction4(BOOL bTeaching);

	BOOL JudgeRetry(int actionNum, BOOL bTeaching);
	void WaitForComData();
    void ClearExpiredFiles();
	void SetupUI();
	void UpdateStatusBar();
	RUN_INFO GetRunInfo();
	void resizeEvent(QResizeEvent* event);
	void AdjustImageUI(bool bResultImage);
	/*signals:
	void setLightEvent();*/
	HalconCpp::HImage CatchBallImage();
	HalconCpp::HImage CatchSubStrateImage();
	HalconCpp::HImage CatchCapImage();
	HalconCpp::HImage CatchCMImage();
		
	void UpdateTypeAndPackage();
	void StartAnalysis();
};

#endif // MAINWINDOW_H
